<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<s:include value="/comm/header.jsp" />
<s:include value="/comm/menu.jsp"/>
<style>
html,body{height:100%;}
body,div,h2{margin:0;padding:0;}
body{font:12px/1.5 Tahoma;}
center{padding-top:10px;}
#moverlay{position:absolute;top:0;left:0;width:100%;_width:2000px;height:100%;_height:2000px;background:#666;opacity:0.5;filter:alpha(opacity=50);display:none;z-index:998;
position:fixed!important;/*FF IE7*/
position:absolute;/*IE6*/_margin-left:-240px;
_top:       expression(eval(document.compatMode &&
            document.compatMode=='CSS1Compat') ?
            documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
            document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/}
#mwin{position:absolute;top:35%;left:48%;width:500px;height:200px;background:#fff;border:2px solid #a00000;display:none;z-index:999;
left:50%;
top:50%;
margin-left:-150px!important;/*FF IE7 该值为本身宽的一半 */
margin-top:-60px!important;/*FF IE7 该值为本身高的一半*/
margin-top:0px;
position:fixed!important;/* FF IE7*/
position:absolute;/*IE6*/
_top:       expression(eval(document.compatMode &&
            document.compatMode=='CSS1Compat') ?
            documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/
            document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/}

h2{font-size:12px;height:18px;text-align:right;background:#A10;border-bottom:0px solid #f90;padding:5px;cursor:move;}
h2 span{color:#f90;cursor:pointer;background:#fff;border:0px solid #f90;padding:0 0px;}
</style>

<script>
$(function(){
	var oWin = document.getElementById("mwin");
	var oLay = document.getElementById("moverlay");	
	var oClose = document.getElementById("mclose");
	var oH2 = oWin.getElementsByTagName("h2")[0];
	var bDrag = false;
	var disX = disY = 0;
	oClose.onclick = function ()
	{
		oLay.style.display = "none";
		oWin.style.display = "none";
		
	};
	oClose.onmousedown = function (event)
	{
		(event || window.event).cancelBubble = true;
	};
	oH2.onmousedown = function (event)
	{		
		var event = event || window.event;
		bDrag = true;
		disX = event.clientX - oWin.offsetLeft;
		disY = event.clientY - oWin.offsetTop;		
		this.setCapture && this.setCapture();		
		return false;
	};
	document.onmousemove = function (event)
	{
		if (!bDrag) return;
		var event = event || window.event;
		var iL = event.clientX - disX;
		var iT = event.clientY - disY;
		var maxL = document.documentElement.clientWidth - oWin.offsetWidth;
		var maxT = document.documentElement.clientHeight - oWin.offsetHeight;		
		iL = iL < 0 ? 0 : iL;
		iL = iL > maxL ? maxL : iL; 		
		iT = iT < 0 ? 0 : iT;
		iT = iT > maxT ? maxT : iT;
		
		oWin.style.marginTop = oWin.style.marginLeft = 0;
		oWin.style.left = iL + "px";
		oWin.style.top = iT + "px";		
		return false;
	};
	document.onmouseup = window.onblur = oH2.onlosecapture = function ()
	{
		bDrag = false;				
		oH2.releaseCapture && oH2.releaseCapture();
	};
});
</script>

<script type="text/javascript">
var mUserId = 0;
$(function(){
	$("#follow").click(function(){
		var p = $(this).attr("p");
		var userId = p.slice(0, -1);
		var flag = p.slice(-1);
		follow(userId, flag);
	});
	
	$("#showmsg").click(function(){
		mUserId = $(this).attr("p");
		showMsg();
	});
	
	$("#sendmsg").click(function(){
		sendMsg();
	});
});

<%-- var bLogin = false;
var fUserId = 0;

var doLogin = function(){
	var mail = $("#amail").val();
	var pwd = $("#apwd").val();
	
	if(!mail && !pwd){
		$("#msg").html("<font color='red'>请输入您的登录邮箱和密码</font>");
		return;
	}
	
	if(!mail){
		$("#msg").html("<font color='red'>请输入您的登录邮箱</font>");
		return;
	}
	
	if(!pwd){
		$("#msg").html("<font color='red'>请输入您的密码</font>");
		return;
	}
	
	$.ajax({
		type:"POST",
		url:"aLogin.htm",
		data:{email:mail, pwd:pwd},
		datatype:"text",
		success:function(data){
			if(data == ""){
				$("#msg").html("<font color='red'>用户名或者密码错误!</font>");
			}else{
				bLogin = true;
				follow(fUserId, 5);
				closeLogin();
				$("#welcome").html("您好，"+data+"&nbsp;&nbsp;<a style='color:#A10000' href='<%=path%>/logout.htm'>退出登录</a>");
			}
	    }
	});
}; --%>

var follow = function(userId, flag){
	var userObj = "${sessionScope.user}";
	if(userObj == '' && !bLogin){
		to = 5;
		fUserId = userId;
		showLogin();
	}else{
		$.ajax({
			type:"POST",
			url:"follow.htm",
			data:{userId:userId, flag:flag},
			datatype:"text",
			success:function(data){
				if(5==flag){
					if(data == "true"){
						$("#follow").attr("p", userId+"2");
						$("#follow").children().attr("src", "images/bg_butb1.png");
					}
				}else{
					if(data == "true"){
						if(1==flag){
							$("#follow").attr("p", userId+"2");
							$("#follow").children().attr("src", "images/bg_butb1.png");
						}else{
							$("#follow").attr("p", userId+"1");
							$("#follow").children().attr("src", "images/bg_butb.png");
						}
					}
			    }
			}
		});
	}
};

var showMsg = function(){
	var userObj = "${sessionScope.user}";
	if(userObj == '' && !bLogin){
		to = 13;
		showLogin();
	}else{
		var oLay = document.getElementById("moverlay");
		var oWin = document.getElementById("mwin"); 
		oLay.style.display = "block";
		oWin.style.display = "block";
	}
};

var sendMsg = function(){
	var content = $("#content").val();
	content = $.trim(content);
	$("#content").val(content);
	if(!content){
		$("#mmsg").html("<font color='red'>发送内容不能为空，请重新输入！</font>");
		return;
	}else{
		if(content.length>300){
			$("#mmsg").html("<font color='red'>发送内容不能超过300个字符！</font>");
			return;
		}
		$.ajax({
			type:"POST",
			url:"sendMsg.htm",
			data:{userId:mUserId, content:content},
			datatype:"text",
			success:function(data){
				if(data == "true"){
					$("#mclose").click();
				}else{
					$("#mmsg").html("<font color='red'>私信发送失败，请稍后再拭！</font>");
				}
			}
		});
	}
};
</script>

<div id="moverlay"  ></div>
<div id="mwin">
<h2><div class="wrap_left"><span class="span_denglu">发消息</span></div>
<span id="mclose"><img src="images/close1.png" border="0"/></span></h2>

	<div class="reg_message">
				<div id="mmsg" align="center"></div>
            	<li><textarea id="content" rows="4" cols="80"></textarea></li>
              <li><div id="button" class="login_but"><span style=" margin-left:70px"><a style="cursor:pointer" class="login" id="sendmsg">发送私信</a></span></div></li>
            </div>
</div>

<!--第1部分开始  --> 
    <div class="wrap1">
    	<div class="blank1"></div>
        
    	<div class="agent_outbox">
        	<div class="wrap_left">
            	<div class="agent_box1">
                	<div class="agent_box_wrap">
                		<div class="wrap_left"><span class="agent_head"><img src="${userModel.photoUrl120}"/></span></div>
                    	<div class="wrap_left"><span class="agent_tt">${userModel.nickName}</span><br /><span class="agent_star"><img src="images/${userModel.starImg}" /> &nbsp;<span class="span35"><strong>人气：</strong></span><span class="span17">${userModel.followCount}</span></span><br />
                    	<span class="agent_tip"><b>代购行业</b>：
                    	<s:iterator value="userModel.cateList">
                    	${categoryName}&nbsp;
                    	</s:iterator><br />
                    	<b>代购区域</b>：
						<s:iterator value="userModel.areaList">
                    	${areaName}&nbsp;
                    	</s:iterator><br />
						</span></div>
                        <div class="clear"></div>
                        <div class="agent_but">
                        	<div class="wrap_left"><div class="agent_butpic1">
								<s:if test="userModel.followId==0">
									<a id="follow" p="${userModel.userid}1"
										style="cursor: pointer"><img src="images/bg_butb.png"
										border="0" /></a>
								</s:if>
								<s:else>
									<a id="follow" p="${userModel.userid}2"
										style="cursor: pointer"><img src="images/bg_butb1.png"
										border="0" /></a>
								</s:else>
							</div></div>
                            <div class="wrap_right"><a id="showmsg" p="${userModel.userid}"
										style="cursor: pointer"><img src="images/icon_sendmsg.gif"/></a></div>
                            <div class="clear"></div>
                        </div>
                    </div>
               </div>
            </div>
            <div class="wrap_right">
            	<div class="agent_box2">
                	<span class="agent_tip2">经纪格言</span><br />
                    <span class="agent_tip3">${userModel.selfdesc}</span><br />
                </div>
            </div>
            <div class="clear"></div>
        </div>
        
        <div class="blank1"></div>
        <div class="outbox2">
        	<div class="agent_show_tt">
            	<span class="span24">该经纪人共发布了 <span class="showtxt4">${totalSize}</span> 件商品 </span>
            	<span class="span25"><strong>每页显示</strong>&nbsp;&nbsp;<a href="brokerDetail.htm?pageSize=20&superPage=${superPage }&id=${userModel.userid}">10</a>&nbsp;&nbsp;<a href="brokerDetail.htm?pageSize=10&superPage=${superPage }&id=${userModel.userid}">20</a>&nbsp;&nbsp;<a href="brokerDetail.htm?pageSize=30&superPage=${superPage }&id=${userModel.userid}">30</a></span>	
            </div>
            <div class="clear"></div>
            <!--列表开始-->
<div class="show_list4">
	<ul>
    	<!--循环开始-->
    	<s:iterator value="userModel.canBuyList">
	    	<li>
	        	<span class="showpic1"><a target="_blank" href="<%=path%>/canBuyDetail.htm?id=${canId}"><img src="<s:property value='image200' />" /></a></span><br />
	            <span class="showtxt1">
								<span class="show_list1_tt">
									<a href="canBuyDetail.htm?canBuyModel.canId=<s:property value='canId' />" target="_blank"><s:property value="goodsName" /></a>
								</span><br /> 
								
								<span class="span1">价格：</span><span class="span2">￥<s:property value="price" /></span><br />
                                <span class="span1">佣金</span>：<span>￥${serviceFee}</span><span class="span1">　|　<s:property value="areaName" /></span><br />
                                <span class="span1"><a href="brokerDetail.htm?id=<s:property value='user.userid' />" taget="_blank"><s:property value='user.nickName' /></a></span><span class="span1">　|　已有<s:property value='transNum' />人代购</span>
							</span>
	        </li>
        </s:iterator>
        <!--循环结束-->
    </ul>
</div>  
        <!--列表结束--> 
        </div>
<div class="clear"></div>      
<!--页码开始-->
<div class="page_box">
<div class="pagewrap">
	<div class="page">
    	<s:if test="totalSize > 0">
						<ul>
							<s:if test="superPage == 1">
								<li>首页</li>
								<li>上一页</li>
							</s:if>
							<s:else>
								<s:url id="first" action="brokerDetail">
									<s:param name="pageSize" value="pageSize" />
									<s:param name="superPage" value="1"/>
									<s:param name="id" value="userModel.userid" />
								</s:url>
								<s:url id="prev" action="brokerDetail">
									<s:param name="pageSize" value="pageSize" />
									<s:param name="superPage" value="superPage - 1"/>
									<s:param name="id" value="userModel.userid" />
								</s:url>
								<li><s:a href="%{first}">首页</s:a></li>
								<li><s:a href="%{prev}">上一页</s:a></li>
							</s:else>
							<s:iterator value="pageList" status="st">
								<s:if test="pageNumber == '...'">
									<li><s:property value='pageNumber' /></li>
								</s:if>
								<s:elseif test="choose">
									<li class="thisclass"><s:property value='pageNumber' /></li>
								</s:elseif>
								<s:else>
									<s:url id="page#st.index" action="brokerDetail">
										<s:param name="pageSize" value="pageSize" />
										<s:param name="superPage" value="pageNumber"/>
										<s:param name="id" value="userModel.userid" />
									</s:url>
									<li><s:a href="%{page#st.index}"><s:property value='pageNumber' /></s:a></li>
								</s:else>
								
							</s:iterator>
							<s:if test="superPage == totalPage">
								<li>下一页</li>
								<li>末页</li>
							</s:if>
							<s:else>
								<s:url id="next" action="brokerDetail">
									<s:param name="pageSize" value="pageSize" />
									<s:param name="superPage" value="superPage + 1"/>
									<s:param name="id" value="userModel.userid" />
								</s:url>
								<s:url id="last" action="brokerDetail">
									<s:param name="pageSize" value="pageSize" />
									<s:param name="superPage" value="totalPage"/>
									<s:param name="id" value="userModel.userid" />
								</s:url>
								<li><s:a href="%{next}">下一页</s:a></li>
								<li><s:a href="%{last}">末页</s:a></li>
							</s:else>
							<li><span class="pageinfo">共 <strong><s:property value='totalPage' /></strong>页<strong><s:property value='totalSize' /></strong>条
							</span></li>
							<div class="clear"></div>
						</ul>
			</s:if>
	</div>
</div>

</div>
<!--页码结束 --> 

    </div>


<!--第1部分结束  --> 
<s:include value="/comm/bottom.jsp"/>
